#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
    int a;
    int b, count = 0;
    scanf("%d %d", &a,&b);
    for (int i = 1; i <= a; i++)
    {
        int m = i;
        while (m)
        {
            if (b == m % 10)
            {
                count++;
            }
            m /= 10;
        }
    }
    printf("%d", count);
    return 0;
}